package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.common.persistence.model.TOrderFeeLog;
import com.stylefeng.guns.modular.system.service.ITOrderFeeLogService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-03-10 09:39:53
 */
@Controller
@RequestMapping("/tOrderFeeLog")
public class TOrderFeeLogController extends BaseController {

    private String PREFIX = "/system/tOrderFeeLog/";

    @Autowired
    private ITOrderFeeLogService tOrderFeeLogService;

    /**
     * 跳转到首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tOrderFeeLog.html";
    }

    /**
     * 跳转到添加
     */
    @RequestMapping("/tOrderFeeLog_add")
    public String tOrderFeeLogAdd() {
        return PREFIX + "tOrderFeeLog_add.html";
    }

    /**
     * 跳转到修改
     */
    @RequestMapping("/tOrderFeeLog_update/{tOrderFeeLogId}")
    public String tOrderFeeLogUpdate(@PathVariable Integer tOrderFeeLogId, Model model) {
        TOrderFeeLog tOrderFeeLog = tOrderFeeLogService.selectById(tOrderFeeLogId);
        model.addAttribute("item",tOrderFeeLog);
        LogObjectHolder.me().set(tOrderFeeLog);
        return PREFIX + "tOrderFeeLog_edit.html";
    }

    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return tOrderFeeLogService.selectList(null);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TOrderFeeLog tOrderFeeLog) {
        tOrderFeeLogService.insert(tOrderFeeLog);
        return super.SUCCESS_TIP;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tOrderFeeLogId) {
        tOrderFeeLogService.deleteById(tOrderFeeLogId);
        return SUCCESS_TIP;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TOrderFeeLog tOrderFeeLog) {
        tOrderFeeLogService.updateById(tOrderFeeLog);
        return super.SUCCESS_TIP;
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{tOrderFeeLogId}")
    @ResponseBody
    public Object detail(@PathVariable("tOrderFeeLogId") Integer tOrderFeeLogId) {
        return tOrderFeeLogService.selectById(tOrderFeeLogId);
    }
}
